package com.threeti.mecool.legacy.domain.model.basicdata;

public class MDProduct {
    private String code;
    private String sku;
    private MDBrand brand;

    public MDProduct(String code, String sku, MDBrand brand) {
        this.code = code;
        this.sku = sku;
        this.brand = brand;
        brand.addProducts(this);
    }

    public String getCode() {
        return code;
    }

    public String getSku() {
        return sku;
    }

    public MDBrand getBrand() {
        return brand;
    }

    @Override
    public int hashCode() {
        return code != null ? code.hashCode() : super.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) return true;
        if (code != null && obj instanceof MDProduct) {
            return code.equals(((MDProduct) obj).code);
        }
        return false;
    }
}
